home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pas_all.zip / TI161.ASC < prev    next >
Text File  |  1992-09-02  |  6KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.   PRODUCT : TURBO PASCAL                               NUMBER : 161
  10.   VERSION : 2.0xx, 3.0xx
  11.        OS : MSDOS
  12.      DATE : March 13, 1986                               PAGE : 1/3
  13.     TITLE : MEMORY MAP INFORMATION
  14.  
  15.  
  16.  
  17.  
  18.   1.   When TURBO.COM is executed, MS-DOS builds a program segment
  19.        prefix in the lower 100H bytes of memory, and loads the
  20.        code immediately above. MS-DOS then jumps to CS: 100H.  When
  21.        Turbo Pascal gains control, it sets the DS register to point
  22.        at the fir
  23.  
  24.        In systems with little RAM, Memtop-DS may be less than 1000H
  25.        (64K bytes), and in that case SS is set to the same
  26.        paragraph address as DS and SP is set to (Memtop-DS)?16.  In
  27.        the maps that follow we assume that Memtop-DS is greater
  28.        than 1000H.
  29.  
  30.        When using the Editor, memory is mapped as follows:
  31.  
  32.      CS:0000 - CS:00FF   MS-DOS PROGRAM SEGMENT PREFIX
  33.      CS:0100 - CS:E0RC   RUN-TIME LIBRARY CODE
  34.      CS:E0RC - CS:E0CC   MONITOR, EDITOR AND COMPILER CODE
  35.      DS:0000 - DS:E0RW   RUN-TIME LIBRARY DATA
  36.      DS:E0RW - DS:E0CW   MONITOR, EDITOR AND COMPILER DATA
  37.      DS:E0CW - DS:EOEM   ERROR MESSAGES (IF LOADED)
  38.      DS:E0EM - DS:????   SOURCE TEXT
  39.      SS:???? - SS:FFFF   CPU STACK
  40.  
  41.  
  42.        When the compiler is invoked to compile a program in memory,
  43.        it creates a new code segment immediately above the source
  44.        text. The PSP (Program Segment Prefix) and the run-time
  45.        library are copied from Turbo Pascal's code segment. The
  46.        reason Turbo Pasc
  47.  
  48.      CS:0000 - CS:00FF   MS-DOS PROGRAM SEGMENT PREFIX
  49.      CS:0100 - CS:E0RC   RUN-TIME LIBRARY CODE
  50.      CS:E0RC - CS:E0CC   MONITOR, EDITOR AND COMPILER CODE
  51.      DS:0000 - DS:E0RW   RUN-TIME LIBRARY DATA
  52.      DS:E0RW - DS:EOCW   MONITOR, EDITOR AND COMPILER DATA
  53.      DS:E0CW - DS:E0EM   ERROR MESSAGES (IF LOADED)
  54.      DS:O0EM - DS:EOST   SOURCE TEXT
  55.  
  56.      CP:0000 - CP:00FF   MS-DOS PROGRAM SEGMENT PREFIX (COPY)
  57.      CP:0100 - CP:E0RC   RUN-TIME LIBRARY CODE (COPY)
  58.      CP:E0RC - CP:????   PROGRAM CODE
  59.      SS:???? - SS:FC00   SYMBOL TABLE
  60.      SS:???? - SS:FFFF   CPU STACK
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.   PRODUCT : TURBO PASCAL                               NUMBER : 161
  76.   VERSION : 2.0xx, 3.0xx
  77.        OS : MSDOS
  78.      DATE : March 13, 1986                               PAGE : 2/3
  79.     TITLE : MEMORY MAP INFORMATION
  80.  
  81.  
  82.  
  83.  
  84.        To execute the finished program, Turbo Pascal simply does a
  85.        far jump to offset 100H in the new program segment  (CP). It
  86.        will then look to the program as if it had been executed
  87.        from MS-DOS.
  88.  
  89.        When a Turbo Pascal program is executed in memory or from
  90.        MS-DOS, it maps memory as shown below:
  91.  
  92.      CS:0000 - CS:00FF   MS-DOS PROGRAM SEGMENT PREFIX (COPY)
  93.      CS:0100 - CS:E0RC   RUN-TIME LIBRARY CODE (COPY)
  94.      CS:E0RC - CS:E0PC   PROGRAM CODE
  95.      DS:0000 - DS:E0RW   RUN-TIME LIBRARY DATA
  96.      DS:E0RW - DS:E0PW   PROGRAM DATA
  97.      HS:0000 - ???????   HEAP (TOP ADDRESS IN HEAPPTR)
  98.      SS:???? - SS:FFFF   CPU STACK
  99.  
  100.        On entry, DS is set to point just above the code segment,
  101.        and the heap pointer (HeapPtr) is set to point just above
  102.        the data segment. SS:SP is set to point at top of memory,
  103.        using the same technique as when Turbo Pascal itself is
  104.        executed.
  105.  
  106.        When a program terminates, it either returns to MS-DOS
  107.        (using system function 0) or it does a far jump back to
  108.        Turbo Pascal, depending on a flag in the program code.
  109.  
  110.        Typed constants are stored in the code segment and, except
  111.        for their base segment (CS versus DS), correspond to
  112.        variables in all aspects. Untyped constants are never stored
  113.        in the sense that they have a fixed address somewhere in
  114.        memory. An untyped con
  115.  
  116.   2.   There is no recursion stack in the 16-bit versions of Turbo
  117.        Pascal. It is only in the 8-bit version that the CPU stack
  118.        and the recursion stack are separated. The 16-bit version
  119.        implements a true "stack frame" concept, meaning that all
  120.        local variable
  121.  
  122.   3.   The CSEG, DSEG, and SSEG return the contents of the CS, DS,
  123.        and SS Registers, respectively. However, contrary to the
  124.        other segment registers, the value of the ES register is not
  125.        fixed. Turbo Pascal will initialize it when it uses it. ES
  126.        is used heav
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.   PRODUCT : TURBO PASCAL                               NUMBER : 161
  142.   VERSION : 2.0xx, 3.0xx
  143.        OS : MSDOS
  144.      DATE : March 13, 1986                               PAGE : 3/3
  145.     TITLE : MEMORY MAP INFORMATION
  146.  
  147.  
  148.  
  149.  
  150.   4.   The fields of the PSP are easily accessed by declaring them
  151.        as absolute variables in the code segment. For instance:
  152.  
  153.        var CMDLine: String(127) absolute CSeg:$80H
  154.  
  155.        which declares a variable to access the command line passed
  156.        by MS-DOS in the PSP.
  157.  
  158.        The chain and execute procedures store 0FF in the byte at
  159.        CS:80H to indicate that the program was invoked from another
  160.        program and not from MS-DOS. Otherwise, the PSP is not
  161.        changed during a chain/execute operation. Turbo Pascal only
  162.        accesses the PSP
  163.  
  164.   5.   There is no official way to catch run-time errors in the
  165.        current versions of Turbo Pascal.
  166.  
  167.   6.   When a COM File is invoked from MS-DOS, all segment
  168.        registers are set to point at the program segment prefix.
  169.        This initial value is retained in the CS register during
  170.        execution, and you can obtain it through the CSEG function.
  171.  
  172.   7.   Turbo Pascal initializes the divide-by-zero interrupt vector
  173.        (Interrupt 0). When the U compiler option is activated with
  174.        an {$U+} directive, Turbo Pascal initializes interrupt
  175.        vector 3 to point at a Ctrl-C check routine. In both cases,
  176.        MS-DOS syst
  177.  
  178.   8.   There is no additional information available on the inner
  179.        workings of the Turbo Pascal initialization routines (front
  180.        end). However, most if not all of the tasks carried out by
  181.        it are covered in the reference manual and the above
  182.        answers.
  183.  
  184.  
  185.   DISCLAIMER: You have the right to use this technical information
  186.   subject to the terms of the No-Nonsense License Statement that
  187.   you received with the Borland product to which this information
  188.   pertains.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.